package org.dwell.nutzcow.book.ioc.basic1;

import org.nutz.ioc.Ioc;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.json.JsonLoader;

/**
 * Created by Jange on 2016/3/30.
 */
public class TeacherIocTest {
    public static void main(String[] args) {
        Ioc ioc = new NutIoc(new JsonLoader("teacher.js"));
        Teacher teacher = ioc.get(Teacher.class, "emily");
        System.out.printf("%s - [%s]\n", teacher.getName(), teacher.getAge());
//        System.out.println(teacher.getFriend().getName());

        Teacher teacher1 = ioc.get(null, "gujian");
        System.out.printf("%s's friend is %s\n", teacher1.getName(), teacher1.getFriend().getName());

        Teacher teacher2 = ioc.get(null, "gujian");
        //因为设置了singleton=true，所以两个teacher相等
        System.out.println(teacher1 == teacher2);

        ioc.depose();       //关闭ioc容器
    }
}
